﻿using System;

namespace TaskBoardProject
{
    class Program
    {
        static void Main(string[] args)
        {
            #region Volodymyr Komaniak - implementation of ICloneable interface using method Clone()
            var beforeCloning = new Task(); // declare instance of class "Task", 
                                             // which contain all fields;
            var afterCloning = new Task(); // declare instance of class "Task", 
                                            // which will be cloning;
            // implementation exception handling for cloning function;
            try
            {              
                afterCloning = (Task)beforeCloning.Clone(); // declare other instance of class "Task", 
                                                            // which clones fields of class "Task";              
            }
            catch (System.OutOfMemoryException ex) // shows, is there enough memory for cloning objects;
            {
                Console.WriteLine(ex);
            }
            Console.WriteLine("Please, write new projectName, for example 'First project'");
            afterCloning.ProjectName = Console.ReadLine(); // change value of "projectName" 
            // for comparison cloned values of field;
            // verification to equality;
            if ((beforeCloning.ProjectName.Equals(afterCloning.ProjectName)) == true)
            {
                Console.WriteLine("\nDeep cloning did not occur");
            }
            else
            {
                Console.WriteLine("\nAll right, it's deep copy");
            }
            Console.WriteLine("\nPresentation of fields before cloning and after cloning");
            // presentation of fields before cloning;
            Console.WriteLine("\nFields beforeCloning:\n \nProjectName: {0}" +
                "\nTaskName: {1} \nTaskPriority: {2} \nTimeFrom: {3}" +
                "\nTimeTo: {4} \nAssignedEmploye: {5}",
                    beforeCloning.ProjectName,
                    beforeCloning.TaskName,
                    beforeCloning.TaskPriority,
                    beforeCloning.TimeFrom,
                    beforeCloning.TimeTo,
                    beforeCloning.AssignedEmploye);

            // presentation of fields after cloning;
            Console.WriteLine("\nFields afterCloning:\n \nProjectName: {0}" +
                "\nTaskName: {1} \nTaskPriority: {2} \nTimeFrom: {3}" +
                "\nTimeTo: {4} \nAssignedEmploye: {5}",
                    afterCloning.ProjectName,
                    afterCloning.TaskName,
                    afterCloning.TaskPriority,
                    afterCloning.TimeFrom,
                    afterCloning.TimeTo,
                    afterCloning.AssignedEmploye);
            Console.ReadLine();
            #endregion


            
            var myBoard = new TaskBoard { new Task(), new Task(), new Task(), new Task() };

            
            foreach(Task t in myBoard)
            {
                Console.WriteLine(t.ToString());
            }
            Console.ReadLine();

            //testing Equals and GetHashCode
            //Task firstTask = new Task("FirstProject", "FirstTask", "alala", TaskPriority.High, DateTime.Now, DateTime.Now, "MartaKorol");
            //Task secondTask = new Task();
            //Task cloneFirstTask = firstTask.Clone() as Task;
            //Console.WriteLine("Does firstTask equal to secondTask? - {0}\n HashCode firstTask : {1}\n HashCode secondTask : {2}\n", firstTask.Equals(secondTask), firstTask.GetHashCode(), secondTask.GetHashCode());
            //if (cloneFirstTask != null)
            //{
            //    Console.WriteLine("Does firstTask equal to cloneFirstTask? - {0}\n HashCode firstTask : {1}\n HashCode cloneFirstTask : {2}\n", firstTask.Equals(cloneFirstTask), firstTask.GetHashCode(), cloneFirstTask.GetHashCode());
            //}
//<<<<<<< .mine
            
            
            //#region Marta Korol - Testing Basic Methods
            //Console.WriteLine("Testing Task's basic methods");
            //Task firstTask = new Task("FirstProject", "FirstTask", "alala", TaskPriority.High, DateTime.Now, DateTime.Now, "Marta Korol");
            //Task secondTask = new Task();
            //Task cloneFirstTask = firstTask.Clone() as Task;
            //Console.WriteLine("Is firstTask equal to secondTask? - {0}\n Same hashcodes? - {1}\n", firstTask.Equals(secondTask), firstTask.GetHashCode() == secondTask.GetHashCode());
            //Console.WriteLine("Is firstTask equal to cloneFirstTask? - {0}\n Same hashcodes? - {1}\n", firstTask.Equals(cloneFirstTask), firstTask.GetHashCode()==cloneFirstTask.GetHashCode());

            //Console.WriteLine("Testing TaskBoard's basic methods");
            //TaskBoard firstBoard = new TaskBoard();
            //firstBoard.Add(firstTask);
            //firstBoard.Add(secondTask);
            //firstBoard.Add(secondTask);

            //TaskBoard secondBoard = new TaskBoard();
            //secondBoard.Add(firstTask);
            //secondBoard.Add(secondTask);
            //secondBoard.Add(firstTask);

            //TaskBoard thirdBoard = new TaskBoard();
            //thirdBoard.Add(firstTask);
            //thirdBoard.Add(secondTask);
            //thirdBoard.Add(secondTask);
            //Console.WriteLine("Is firstBoard equal to secondBoard? - {0}\n Same hashcodes? - {1}\n", firstBoard.Equals(secondBoard), firstBoard.GetHashCode() == secondBoard.GetHashCode());
            //Console.WriteLine("Is firstBoard equal to thirdBoard? - {0}\n Same hashcodes? - {1}\n", firstBoard.Equals(thirdBoard), firstBoard.GetHashCode() == thirdBoard.GetHashCode());
           
            //#endregion
            

            /*
            #region Oleg Shogryn OutlookService Test
            Task tsk = new Task("Project", "Task", "This is Task", TaskPriority.Low, new DateTime(2014, 6, 25), new DateTime(2014, 7, 25), "Shtogryn Oleg");
            Task importTask;

            using (OutlookService oService = new OutlookService())
            {
                oService.SaveAsOutlookTask(tsk);
                importTask = oService.GetOutlookTaskBySubjet();
            }
            if (importTask != null)
            {
                Console.WriteLine("This is imported task: {0}, {1}", importTask.TaskName, importTask.TaskPriority);
            }
            #endregion
            */
            Console.ReadLine();
        }
    }
}
